@@ -61,6 +61,19 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
61 | 61 |
} |
62 | 62 |
} |
63 | 63 |
|
64 |
+ public synchronized void addPreviousPhotos(ArrayList<PhotoBean> photos){ |
|
65 |
+ if(photos==null||photos.size()==0){ |
|
66 |
+ return; |
|
67 |
+ } |
|
68 |
+ if(photoList==null){ |
|
69 |
+ photoList = new ArrayList<>(); |
|
70 |
+ } |
|
71 |
+ if(photoList.size()==0){ |
|
72 |
+ photoList.addAll(photos); |
|
73 |
+ notifyDataSetChanged(); |
|
74 |
+ } |
|
75 |
+ } |
|
76 |
+ |
|
64 | 77 |
public synchronized void removePhotoAtIndex(int index){ |
65 | 78 |
if(photoList==null || photoList.size()<=index){ |
66 | 79 |
return; |
@@ -17,6 +17,7 @@ import com.android.common.utils.LogHelper; |
||
17 | 17 |
import com.umeng.analytics.MobclickAgent; |
18 | 18 |
|
19 | 19 |
import java.io.File; |
20 |
+import java.util.ArrayList; |
|
20 | 21 |
|
21 | 22 |
import ai.pai.lensman.BuildConfig; |
22 | 23 |
import ai.pai.lensman.R; |
@@ -200,6 +201,20 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
200 | 201 |
} |
201 | 202 |
|
202 | 203 |
@Override |
204 |
+ public void addPhotos(final ArrayList<PhotoBean> photoList) { |
|
205 |
+ if(photoList==null||photoList.size()<1) { |
|
206 |
+ return; |
|
207 |
+ } |
|
208 |
+ photosRecyclerView.post(new Runnable() { |
|
209 |
+ @Override |
|
210 |
+ public void run() { |
|
211 |
+ adapter.addPreviousPhotos(photoList); |
|
212 |
+ photosRecyclerView.smoothScrollToPosition(photoList.size()-1); |
|
213 |
+ } |
|
214 |
+ }); |
|
215 |
+ } |
|
216 |
+ |
|
217 |
+ @Override |
|
203 | 218 |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
204 | 219 |
super.onActivityResult(requestCode,resultCode,data); |
205 | 220 |
if (resultCode == Activity.RESULT_OK) { |
@@ -1,5 +1,7 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 |
+import java.util.ArrayList; |
|
4 |
+ |
|
3 | 5 |
import ai.pai.lensman.base.BasePresenter; |
4 | 6 |
import ai.pai.lensman.base.BaseView; |
5 | 7 |
import ai.pai.lensman.bean.PhotoBean; |
@@ -15,6 +17,7 @@ public class SessionContract { |
||
15 | 17 |
void showEmptyView(); |
16 | 18 |
void showToast(String toast); |
17 | 19 |
void refreshUploadTimeHint(); |
20 |
+ void addPhotos(ArrayList<PhotoBean> photoList); |
|
18 | 21 |
} |
19 | 22 |
|
20 | 23 |
interface Presenter extends BasePresenter{ |
@@ -49,9 +49,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
49 | 49 |
} |
50 | 50 |
LogHelper.d(TAG,"SessionPresenter start and found old photos, size = "+photoList.size()); |
51 | 51 |
sessionView.showPhotoRecyclerView(); |
52 |
- for (PhotoBean photoBean : photoList) { |
|
53 |
- sessionView.addNewPhoto(photoBean); |
|
54 |
- } |
|
52 |
+ sessionView.addPhotos(photoList); |
|
55 | 53 |
} |
56 | 54 |
interactor.startSession(); |
57 | 55 |
refreshTimer = new Timer(); |